<style>
    label.red-start:before {
        content: '* ';
        color: red;
    }

</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form id="addFrm" class="layui-form" action="" lay-filter="component-form-group">
                <input type="hidden" name="set_second_id" value="<?= $set_second_id ?>">
                <input type="hidden" name="order_id" value="<?= $oldData["id"] ?>">
                <input type="hidden" name="set_day" value="<?= $oldData["set_day"] ?>">
                <input type="hidden" name="set_id" value="<?= $oldData["set_id"] ?>">
                <input type="hidden" name="order_date" value="<?= date("Y-m-d", $oldData["order_date"]) ?>">
                <input type="hidden" name="type_id" value="<?= $oldData["type_id"] ?>">
                <input type="hidden" name="kehu_custom_id" value="<?= $oldData["kehu_custom_id"] ?>">
                <input type="hidden" name="goods_name" value="<?= $oldData["goods_name"] ?>">
                <input type="hidden" name="num" value="<?= $oldData["num"] ?>">
                <input type="hidden" name="weight" value="<?= $oldData["weight"] ?>">
                <input type="hidden" name="xianghao" value="<?= $oldData["xianghao"] ?>">
                <input type="hidden" name="xianghao2" value="<?= $oldData["xianghao2"] ?>">

                <div class="layui-form-item">
                    <label class="layui-form-label">二次类型</label>
                    <div class="layui-input-inline">
                        <select name="second_type_id">
                            <option value="">请选择</option>
                            <?php foreach ($secondType as $k => $v) { ?>
                                <option value="<?= $k ?>"<?= !empty($editData["second_type_id"]) && $editData["second_type_id"] == $k ? " selected" : "" ?>><?= $v["name"] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="order_no" value="<?= !empty($editData['order_no']) ? $editData['order_no'] : $order_no; ?>" autocomplete="off" placeholder="" readonly="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">提货地</label>
                    <div class="layui-input-inline" style="width:500px">
                        <select name="org_id" lay-filter="org_id" lay-search>
                            <option value="">请选择</option>
                            <option value="-1">+新增地址</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item" id="org_address_id" style="display: none">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <select name="org_province_id" lay-filter="org_province_id" lay-search>
                            <option value="">州</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="display: none">
                        <select name="org_city_id" lay-filter="org_city_id">
                            <option value="">城市</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="display: none">
                        <select name="org_district_id" lay-filter="org_district_id">
                            <option value="">区县</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width:285px">
                        <input type="text" name="org_address" value="<?= !empty($editData['org_address']) ? $editData['org_address'] : ""; ?>" autocomplete="off" placeholder="具体地址" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">送货地</label>
                    <div class="layui-input-inline" style="width:500px">
                        <select name="dest_id" lay-filter="dest_id" lay-search>
                            <option value="">请选择</option>
                            <option value="-1">+新增地址</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item" id="dest_address_id" style="display: none">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <select name="dest_province_id" lay-filter="dest_province_id" lay-search>
                            <option value="">省份</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="display: none">
                        <select name="dest_city_id" lay-filter="dest_city_id">
                            <option value="">城市</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="display: none">
                        <select name="dest_district_id" lay-filter="dest_district_id">
                            <option value="">区县</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width:285px">
                        <input type="text" name="dest_address" value="<?= !empty($editData['dest_address']) ? $editData['dest_address'] : ""; ?>" autocomplete="off" placeholder="具体地址" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注/要求</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="" class="layui-textarea" style="width:500px"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn customize" lay-filter="formDemo" id="submitBtn">确定提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="<?= PUBLIC_URL . "/admin/js/order/cityClass.js?" . rand() ?>"></script>
<script>
    var doAddUrl = "<?= $doAddUrl ?>";
    var getCustomAddressUrl = "<?= $this->projectSet["url"]["getCustomAddress"] ?>";
    var getProvinceUrl = "<?= $this->projectSet["url"]["getProvince"] ?>";
    var getCityUrl = "<?= $this->projectSet["url"]["getCity"] ?>";
    var getDistrictUrl = "<?= $this->projectSet["url"]["getDistrict"] ?>";
</script>
<script src="<?= PUBLIC_URL . "/" . $this->projectSet["file"]["js"] . "/addSecondOrder.js?" . rand() ?>"></script>
<script>
    layui.use(['laypage', 'layer', 'form', 'element', 'laydate'], function () {
        var laypage = layui.laypage,
                frm = layui.form,
                layer = layui.layer,
                element = layui.element,
                laydate = layui.laydate;

        frm.on('select(org_id)', function (data) {
            if (data.value == "-1") {
                $("#org_address_id").show();
            } else {
                $("#org_address_id").hide();
            }
        });
        frm.on('select(dest_id)', function (data) {
            if (data.value == "-1") {
                $("#dest_address_id").show();
            } else {
                $("#dest_address_id").hide();
            }
        });

        getOrg(<?= !empty($oldData['kehu_custom_id']) ? $oldData['kehu_custom_id'] : 0; ?>, 0, frm);
        getDest(<?= !empty($oldData['kehu_custom_id']) ? $oldData['kehu_custom_id'] : 0; ?>, 0, frm);

        frm.on('select(org_province_id)', function (data) {
            changeOrgProvince(data.value, frm);
        });
        frm.on('select(org_city_id)', function (data) {
            changeOrgCity(data.value, frm);
        });
        frm.on('select(dest_province_id)', function (data) {
            changeDestProvince(data.value, frm);
        });
        frm.on('select(dest_city_id)', function (data) {
            changeDestCity(data.value, frm);
        });

        getOrgProvince(0, frm);

        getDestProvince(0, frm);
    });
</script>
